$(function() {

    if (typeof(Storage) !== "undefined")
    {
        $.post(localStorage.domain_app+"/webservice/event/getEventDetailById.php", {
            event_id: sessionStorage.event_edit_id,
            user_id: localStorage.userID
        }, function(res) {
            if (res.error == 0) {
                $(".wd-content").html(res.html);
                //call function in event.js
                saveEventID();
                deleteEvent();
                paging_guest();
            } else {
                print_alert(res.msg);
                wd_redirect("event.html");
            }
        }, "json");

    }
    else
    {
        return false;
    }


});
function paging_guest() {
//paging guest going, maybe, not going
    var paging = false;
    $('.wd-more-line').click(function() {
        var show_more = $(this);
        var attend = show_more.attr("rel");
        var end_paging = 0;
        var page = 0;
        if (attend == 0) {
            page = $('#page_maybe').val();
            end_paging = $('#end_paging_maybe').val();
        } else if (attend == 1) {
            page = $('#page_going').val();
            end_paging = $('#end_paging_going').val();
        } else if (attend == 2) {
            page = $('#page_not_going').val();
            end_paging = $('#end_paging_not_going').val();
        }
        if (end_paging == 0) {

            if (paging == false) {
                paging = true;
                $.post(localStorage.domain_app+"/webservice/guest/getInviteGuestByAttend.php", {
                    page: page,
                    event_id: sessionStorage.event_edit_id,
                    user_id: localStorage.userID,
                    attend: attend
                }, function(res) {
                    show_more.before(res.html);
                    if (res.end_paging == 1) {
                        show_more.hide();
                    } else {
                        if (attend == 0) {
                            $('#page_maybe').val(res.page);
                            $('#end_paging_maybe').val(res.end_paging);
                        } else if (attend == 1) {
                            $('#page_going').val(res.page);
                            $('#end_paging_going').val(res.end_paging);
                        } else if (attend == 2) {
                            $('#page_not_going').val(res.page);
                            $('#end_paging_not_going').val(res.end_paging);
                        }
                    }
                    paging = false;
                }, "json");
            } else {
                return false;
            }

        }
    });
}